1.1. Working with Objects
There are a
considerable number of objects available in SharePoint, and as you
might expect, there are more available in SharePoint Server than in
SharePoint Foundation. By reading this article, you might have determined
the relationship between these objects. For example, while a SharePoint
farm can contain many Web applications, each SharePoint farm has one
configuration database. Many of the SharePoint cmdlets use names that
you can easily identify to determine which objects they will
manipulate. To illustrate, the SPFarm cmdlets allow you to retrieve
information about and back up or restore a SharePoint farm. For
example, the SPFarmConfig cmdlet lets you retrieve and set properties for the farm.
However, there are a few cmdlet names that could confuse you. For example, the SPSite cmdlet allows you to manipulate site collections,
explains that you can’t create a site collection unless you have a Web
application, which means using the SPWebApplication object. When a site
collection is created, you choose a site template to create a site. In
the SharePoint Object Model, this site is known as a web
and not a site; hence, the object is named SPWeb. This can be quite
confusing because the term “website” is often shortened to “site,” and
in the SharePoint Object Model, “site collection” is also shortened to
“site.” Because this terminology has been used through many versions of
SharePoint and is used consistently by developers, it is easier for IT
professionals to adopt this usage.
Figure 2
displays the most common objects and their relationships, but there are
others, such as SPSiteCollection, which is a collection of SPSites.
The current selection of
built-in cmdlets does not provide full coverage of all SharePoint
objects, but you can write new cmdlets to manipulate these objects. To
determine the objects associated with
the SharePoint PowerShell cmdlets and the number of cmdlets per each
object, use the commands in the following example, where a portion of
the output is shown.
PS C:\Users\peter> Get-Command -PSSnapin "Microsoft.SharePoint.PowerShell" |
>>sort noun, verb | group-object -property noun
>><ENTER>
Count Name Group
----- ---- -----
1 SPAdminJob {Start-SPAdminJob}
4 SPAlternateURL {Get-SPAlternateURL, New-SPAlternateURL, Rem...
1 SPApplicationContent {Install-SPApplicationContent}
2 SPAssignment {Start-SPAssignment, Stop-SPAssignment}
...(not all output shown)
6 SPWeb {Export-SPWeb, Get-SPWeb, Import-SPWeb, New-...
4 SPWebApplication {Get-SPWebApplication, New-SPWebApplication,...
1 SPWebApplicationExtension {New-SPWebApplicationExtension}
2 SPWebApplicationHttpTh... {Disable-SPWebApplicationHttpThrottling, Ena...
2 SPWebApplicationHttpTh... {Get-SPWebApplicationHttpThrottlingMonitor, ...
3 SPWebPartPack {Get-SPWebPartPack, Install-SPWebPartPack, U...
4 SPWebTemplate {Get-SPWebTemplate, Install-SPWebTemplate, S...
2 SPWorkflowConfig {Get-SPWorkflowConfig, Set-SPWorkflowConfig}